package ru.amse.tsyganov.jumleditor.properties;

import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;

public class PropertiesLabelProvider extends LabelProvider
	implements ITableLabelProvider {

	public Image getColumnImage(Object element, int columnIndex) {
		return PropertiesTable.PROPERTY_VALUE_COLUMN_INDEX == columnIndex ? 
				((Property) element).getImage() : null;
	}

	public String getColumnText(Object element, int columnIndex) {
		Property p = (Property) element;
		
		switch (columnIndex) {
		case PropertiesTable.PROPERTY_NAME_COLUMN_INDEX:
			return p.getPropertyName();
		case PropertiesTable.PROPERTY_VALUE_COLUMN_INDEX:
			return p.getStringPropertyValue();
		}
		
		return null;
	}

}
